/**
 * 构造N*N的矩阵，填入[1...N^2]，要求相邻数字和为偶数
 * 蛇形排位即可
 */
#include <bits/stdc++.h>
using namespace std;

#include <bits/extc++.h>
using namespace __gnu_pbds;

using Real = long double;
using llt = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;

int N;
vvi A;

void proc(){
    A.assign(N, vi(N, 0));
    int k = 0;
    for(int i=0;i<N;i+=2){
        for(int j=0;j<N;++j) A[i][j] = ++k;
        if(i + 1 < N)for(int j=N-1;j>=0;--j) A[i+1][j] = ++k;
    }
    for(auto & a : A){
        for(auto i : a) cout << i << " ";
        cout << endl;
    }
    return;
}

int main(){
#ifndef ONLINE_JUDGE
    freopen("z.txt", "r", stdin);
#endif
    ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(0);
    int nofkase = 1;
    // cin >> nofkase;
    while(nofkase--){
        cin >> N;
        proc();
    }
    return 0;
}